# -*- coding: utf-8 -*-
# @Time : 2021/7/2 10:55
# @Author : feimaotuiya
# @File : page_front_register.py
# @Project : seleniumGitee
from selenium.webdriver.common.by import By


class PageEcshopFrontRegister():
    # 前台注册
    def __init__(self, driver):
        self.driver = driver
        # 元素定位
        self.loc_front_register_username = (By.NAME, "username")
        self.loc_front_register_email = (By.NAME, "email")
        self.loc_front_register_password = (By.NAME, "password")
        self.loc_front_register_confirm_password = (By.NAME, "confirm_password")
        self.loc_front_register_phone = (By.NAME, "extend_field5")
        self.loc_front_register_submit = (By.NAME, "Submit")
        self.loc_front_register_assert = (By.XPATH, '//font[@id="ECS_MEMBERZONE"]/a[1]')
        self.loc_front_register_get_out = (By.XPATH, '//font[@id="ECS_MEMBERZONE"]/a[2]')
        self.loc_front_register_get_login = (By.XPATH, '//font[@id="ECS_MEMBERZONE"]/a[1]')
        self.loc_front_register_assert_1 = (By.XPATH, '/html/body/div[5]/div[3]/div[1]/div[1]/ul/li[1]/a')

    def front_register_username(self, username):  # 输入用户名
        self.driver.find_element(*self.loc_front_register_username).send_keys(username)

    def front_register_email(self, email):  # 输入邮箱
        self.driver.find_element(*self.loc_front_register_email).send_keys(email)

    def front_register_password(self, password):  # 输入密码
        self.driver.find_element(*self.loc_front_register_password).send_keys(password)

    def front_register_confirm_password(self, confirm_password):  # 确认密码
        self.driver.find_element(*self.loc_front_register_confirm_password).send_keys(confirm_password)

    def front_register_phone(self, phone):  # 输入手机号
        self.driver.find_element(*self.loc_front_register_phone).send_keys(phone)

    def front_register_submit(self):  # 点击提交
        self.driver.find_element(*self.loc_front_register_submit).click()

    def front_register_assert(self):  # 断言
        actual = self.driver.find_element(*self.loc_front_register_assert).text
        return actual

    def front_register_get_out(self):
        self.driver.find_element(*self.loc_front_register_get_out).click()

    def front_register_get_login(self):
        self.driver.find_element(*self.loc_front_register_get_login).click()

    def front_register_assert_1(self):
        actual_1 = self.driver.find_element(*self.loc_front_register_assert_1).text
        return actual_1

    def register(self, username, email, password, confirm_password, phone):
        self.front_register_username(username)
        self.front_register_email(email)
        self.front_register_password(password)
        self.front_register_confirm_password(confirm_password)
        self.front_register_phone(phone)
        self.front_register_submit()
        actual = self.front_register_assert()
        return actual

    def register_1(self, username, email, password, confirm_password, phone):
        self.front_register_username(username)
        self.front_register_email(email)
        self.front_register_password(password)
        self.front_register_confirm_password(confirm_password)
        self.front_register_phone(phone)
        self.front_register_submit()
        self.front_register_get_out()
        self.front_register_get_login()
        actual_1 = self.front_register_assert_1()
        return actual_1
